﻿using BigEgg.Framework.Foundation;
using FMStudio.Domain.Properties;
using FMStudio.Domain.Test.MockClasses;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace FMStudio.Domain.Test
{
    [TestClass]
    public class CurrencyExchangeTest
    {
        [TestMethod]
        public void CurrencyExchangeFromValidationTest()
        {
            MockCurrencyExchange currencyExchange = new MockCurrencyExchange();

            Assert.IsNull(currencyExchange.From);
            Assert.AreEqual(Resources.ExchangeFromMandatory, currencyExchange.Validate("From"));

            MockCurrency currency = new MockCurrency();
            currencyExchange.From = currency;
            Assert.AreEqual("", currencyExchange.Validate("From"));
        }

        [TestMethod]
        public void CurrencyExchangeToValidationTest()
        {
            MockCurrencyExchange currencyExchange = new MockCurrencyExchange();

            Assert.IsNull(currencyExchange.To);
            Assert.AreEqual(Resources.ExchangeToMandatory, currencyExchange.Validate("To"));

            MockCurrency currency = new MockCurrency();
            currencyExchange.To = currency;
            Assert.AreEqual("", currencyExchange.Validate("To"));
        }

        [TestMethod]
        public void CurrencyExchangePriceValidationTest()
        {
            MockCurrencyExchange currencyExchange = new MockCurrencyExchange();

            Assert.AreEqual(default(double), currencyExchange.Price);

            currencyExchange.Price = 0.1;
            Assert.AreEqual("", currencyExchange.Validate("Price"));
            currencyExchange.Price = 0.0;
            Assert.AreEqual(Resources.ExchangePriceGreater, currencyExchange.Validate("Price"));
            currencyExchange.Price = -0.1;
            Assert.AreEqual(Resources.ExchangePriceGreater, currencyExchange.Validate("Price"));
        }
    }
}
